package homework3_1;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;



public class Reduce3_1 extends Reducer<IntWritable,NullWritable, IntWritable, IntWritable>{
    int sum=0;
    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {

        Iterator i$ = values.iterator();

        while(i$.hasNext()) {
            sum++;
//          sum记录shuffle后第几次reduce,和K一起打印
            NullWritable value = (NullWritable) i$.next();
            context.write(new IntWritable(sum),key);
        }
    }
}